<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die('Restricted access');
?>

<?php if ($this->params->get( 'show_page_title', 1 ) && $this->params->get('page_title') != '' ) : ?>
	<div class="componentheading<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">
		<?php echo $this->params->get( 'page_title' ).' - detail <span class="stav">('.JText::_('STAV_KU_DNU').' '.StrFTime("%d.%m.%Y", Time()).')</span>'; ?>
  </div>
<?php endif; ?>

<?php echo "<!-- jZmluvy ver.".$this->nastavenie->ver." START -->"; ?>
                                                                       
<?php foreach ($this->items AS $item) : ?>  
<?php $k = 0; $k++; $e=$k%2; ?>  
<?php $link_sub = 'index.php?option=com_jzmluvy&view=faktury&task=download&id='.$item->id ?>  
<?php $link_sub2 = 'index.php?option=com_jzmluvy&view=faktury&task=download2&id='.$item->id ?>     
<?php $link_zml = 'index.php?option=com_jzmluvy&view=zmluvy&layout=detail&id='.$item->typ; ?>
<?php $link_obj = 'index.php?option=com_jzmluvy&view=objednavky&layout=detail&id='.$item->sposob; ?>
<?php if ($this->params->get( 'kontaktlink' ) == 1) {?>   
<?php $link_podpis = "<a href='index.php?option=com_contact&view=contact&id=".$item->created_by_alias."'>".$item->kontakt."</a>"; ?>   
<?php } else $link4 = $item->kontakt; ?> 
<?php $nic = "0000-00-00"; ?> 

<div id="container">

<div id="container-left">
<div id="datum" class="blok">
  <div class="hlavicka"><?php echo JText::_('DET_DAT')?></div>
    <table>
      <?php if($item->publish_up != $nic) : ?>
      <tr>
        <td class="text2"><?php echo JText::_('DAT_DORUCENIA')?>:</td>
        <td class="data2"><?php echo jzmluvyHelper::fdatum($item->publish_up) ?></td>
      </tr>
      <?php endif ?>
      <?php if($item->datZver != $nic) : ?>
      <tr>
        <td class="text2"><?php echo JText::_('DET_ZVEREJNENIA')?>:</td>
        <td class="data2"><?php echo jzmluvyHelper::fdatum($item->datZver) ?></td>
      </tr>
      <?php endif ?>
      <?php if($item->publish_down != $nic) : ?>
      <tr>
        <td class="text2"><?php echo JText::_('DAT_SPLATNOSTI')?>:</td>
        <td class="data2"><?php echo jzmluvyHelper::fdatum($item->publish_down) ?></td>
      </tr>
      <?php endif ?>     
      <?php if($item->datUhrady != $nic) : ?>
      <tr>
        <td class="text2"><?php echo JText::_('DAT_UHRADY')?>:</td>
        <td class="data2"><?php echo jzmluvyHelper::fdatum($item->datUhrady) ?></td>
      </tr>
      <?php endif ?>  
    </table>
</div> 

<?php if (!empty($item->file) || !empty($item->file2)) : ?>
<div id="subory" class="blok">
  <div class="hlavicka"><?php echo JText::_('FA_SUBOR')?></div>
    <table>
      <?php if(!empty($item->file)) : //*** subor sken ?>       
      <tr>
        <td class="subor">
          <?php echo jzmluvyHelper::subor_scan($item->id,$item->file,$item->filename,$item->extension,$link_sub,$item->hits,$item->title,1) ?>
        </td>
        <td class="data2"><?php echo $item->file ?></td>
      </tr>
      <?php endif ?>
      <?php if(!empty($item->file2)) : //*** subor text ?>       
      <tr>
        <td class="subor">
          <?php echo jzmluvyHelper::subor_text($item->id,$item->file2,$item->filename2,$item->extension2,$link_sub2,$item->hits2,$item->title,1) ?>
        </td>
        <td class="data2"><?php echo $item->file2 ?></td>
      </tr>
      <?php endif ?>
    </table>
</div>
<?php endif ?>                        
</div>

<div id="identifikacia" class="blok">
  <div class="hlavicka"><?php echo JText::_('DET_IDENT_FAKTURY') ?>:&nbsp;<span class="bold"><?php echo $item->faktura ?></span></div>
    <table>
      <?php if(!empty($item->faktura)) : ?>
      <tr>
        <td class="text"><?php echo JText::_('DET_IDENT_INT_FAK')?>:</td>
        <td class="data"><?php echo $item->faktura ?>
        <?php if($this->nastavenie->debug) { echo "<em> (".$item->id.")</em>"; } ?>
        </td>
      </tr>
      <?php endif ?>
      <?php if(!empty($item->intCislo)) : ?>
      <tr>
        <td class="text"><?php echo JText::_('IDENT_FAK_INT') ?>:</td>
        <td class="data"><?php echo $item->intCislo; ?></td>
       </tr><?php endif; ?>      
      <?php if(!empty($item->typ) || !empty($item->vlastni1) || !empty($item->jedcislo)) : ?>
      <tr>
        <td class="text"><?php echo JText::_('DET_IDENT_ZMLUVY') ?>:</td>
        <td class="data">
  
     <?php //*** identifikacia zmluvy - linkovane -- nefunguje parameters ?>
     <?php if(!$item->typ_zml) : $item->typ_zml = $item->typ_zml2; endif; ?>
     <a href="<?php echo $link_zml; ?>">
     <?php echo (empty($item->typ_zml)) ? $item->zml_text : $item->typ_zml; ?></a>
     <?php if($item->jedcislo && $item->vlastni1 && $this->nastavenie->crz) : ?>
     <a href="http://<?php echo $item->vlastni1; ?>" target="_blank" title=""><?php echo $item->jedcislo; ?></a>
     <img src="administrator/components/com_jzmluvy/assets/ext_link.png" height="10" width="10" title="Externý odkaz" alt="Ikona" />
     <?php elseif($this->nastavenie->crz) : ?>
     <?php echo $item->jedcislo; ?>
     <?php else : ?>
     <?php endif; ?>

        </td>
      </tr>
      <?php endif ?>
      <?php if(!empty($item->sposob)) : ?>
      <tr>
        <td class="text"><?php echo JText::_('DET_IDENT_OBJEDNAVKY') ?>:</td>
        <td class="data">
        <?php if(!$item->typ_obj) : $item->typ_obj = $item->typ_obj2; endif; ?>
          <a href="<?php echo $link_obj ?>">
            <?php echo $item->typ_obj; ?>
          </a>
        </td>
      </tr>
      <?php endif ?>      
      <tr>
        <td class="text"><?php echo JText::_('DET_IDENT_DODAVATEL')?>:</td>
        <td class="data"><?php echo $item->fadod ?></td>
      </tr>
      <tr>
        <td class="text">&nbsp;</td>
        <td class="data"><?php echo $item->ulica ?></td>
      </tr>
      <tr>
        <td class="text">&nbsp;</td>
        <td class="data"><?php echo $item->psc." ".$item->mesto ?></td>
      </tr>
      <?php if (!empty($item->ico)) : ?>      
      <tr>
        <td class="text"><?php echo JText::_('DET_IDENT_ICO') ?>:</td>
        <td class="data"><?php echo $item->ico ?></td>
      </tr>
      <?php endif ?>
      <tr>
        <td class="text"><?php echo JText::_('DET_IDENT_PREDMET')?>:</td>
        <td class="data"><?php echo $item->title ?></td>
      </tr>                     
      <?php if (!empty($item->fulltext)) : ?>
      <tr>
        <td class="poznamka" colspan="2"><strong><?php echo JText::_('DET_IDENT_POZNAMKA') ?>:&nbsp;</strong><?php echo $item->fulltext ?></td>
      </tr>
      <?php endif ?>                     
    </table>
</div>

<div id="suma" class="blok">
  <div class="hlavicka">
    <?php echo JText::_('DET_SUMA')?>
    <?php echo ($this->nastavenie->dph) ? JText::_('DET_DPH') : JText::_('DET_BEZDPH'); ?>
  </div>
    <table>
      <tr>
        <td class="suma-lft">
          <?php echo JText::_('DET_SUMA_CIASTKA').":"?>
        </td>
        <td class="suma-rgt"><?php echo jzmluvyHelper::fsuma($item->suma,$item->mena) ?></td>
      </tr>
    </table>
</div>
<?php endforeach ?>
</div>
<div class="clr"></div> 

<div class="back_button">    
  <a href='javascript:history.go(-1)'>
    <?php echo JText::_('SPAT').""?></a>  
</div>
<?php echo "<!-- jZmluvy ver.".$this->nastavenie->ver." STOP -->"; ?>